import socket
ip="localhost"
port=6677
with socket.create_connection((ip,port)) as sock:
    while True:
        msg = input("请输入：")
        sock.send(msg.encode("utf-8"))
        recv = sock.recv(1024)
        if len(recv) == 0:
            print("连接已关闭")
            break
        else:
            print("recv: ",recv.decode("utf-8"))

print("程序结束")